﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="TreeCategories.ascx.cs" Inherits="UserControls_TreeCategories" %>

<link type="text/css" rel="Stylesheet" href="../css/form.css" />
<link href="../css/tables.css" type="text/css" rel="Stylesheet" />
<script language="javascript" type="text/javascript" src="../js/jquery-1.2.6.js"></script>
<script language="javascript" type="text/javascript" src="../js/common.js"></script>
<%--<ajaxtoolkits:toolkitscriptmanager runat="server" id="scriptManager"></ajaxtoolkits:toolkitscriptmanager>--%>
<div class="InputRow">
    <asp:textbox runat="server" id="tbCategory" cssclass="SingleLine" readonly="true"></asp:textbox>
    <asp:hyperlink runat="server" id="btChangeCategory" text="<%$ Resources:Strings, Change %>" cssclass="buttonHL"></asp:hyperlink>
    <a class="buttonHL" onclick="clearSelection()"><%= Resources.Strings.Clear %></a>
</div>
<asp:panel runat="server" id="panelCategories" style="display: none" cssclass="panelTree">
        <asp:updatepanel id="UpdatePanel1" runat="server">
            <contenttemplate>
                <asp:treeview runat="server" id="treeCategories" width="250px" height="300px" selectednodestyle-backcolor="Blue" selectednodestyle-forecolor="White"
                style="overflow-y: scroll;overflow-x: scroll;background-color:White; margin:2px 2px 2px 2px; border:solid 2px #96ffaf;"
                onselectednodechanged="selectedNodeChange">
                </asp:treeview>
                <asp:hiddenfield id="hdCategoryId" runat="server" />
                <asp:hiddenfield id="hdCategoryName" runat="server" />
                <asp:hiddenfield id="hdTrue" runat="server" />
            </contenttemplate>
        </asp:updatepanel>
        <div class="InputRow">
            <label class="Label">&nbsp;&nbsp;</label>
            <asp:Button id="btOk" runat="server" text="<%$ Resources:Strings, Ok%>"/>
            <asp:Button id="btCancel" runat="server" text="<%$ Resources:Strings, Cancel%>" />
        </div>
    </asp:panel>
    
    <ajaxtoolkits:modalpopupextender id="ModalPopupExtender" runat="server" 
            TargetControlID="btChangeCategory"
            PopupControlID="panelCategories" 
            BackgroundCssClass="modalBackground" 
            OkControlID="btOk"
            onokscript="chooseCategory()"
            oncancelscript="hidePanel()"
            CancelControlID="btCancel" 
            DropShadow="true" />
    <one:validationmanager id="validationManager" runat="server" formtovalidate="aspnetForm"/>
    <script language="javascript">
        function chooseCategory() {
            var hdId = document.getElementById('<%= hdCategoryId.ClientID %>');
            var hdName = document.getElementById('<%= hdCategoryName.ClientID %>');
            var hdTrue = document.getElementById('<%= hdTrue.ClientID %>')

            if (hdId.value != "" && hdName.value != "") {
                var tbName = document.getElementById('<%= tbCategory.ClientID %>');
                tbName.value = hdName.value;
                hdTrue.value = hdId.value;
            }
            hidePanel();
        }

        function hidePanel() {
            $('.panelTree').css('display', 'none');
        }

        function clearSelection() {
            var hdTrue = document.getElementById('<%= hdTrue.ClientID %>')
            var tbName = document.getElementById('<%= tbCategory.ClientID %>');
            hdTrue.value = 0;
            tbName.value = "";
        }
    </script>